<?php
/**
 * Created by PhpStorm.
 * User: WormW
 * Date: 2017/7/12 0012
 * Time: 15:50
 */

namespace app\admin\controller;


use app\common\model\QbankName;
use think\Controller;
use think\Request;

/**
 * Class Qbank
 * @package app\admin\controller
 */
class Qbank extends Controller
{
    /**
     * @return \think\response\View
     */
    public function lst()
    {
        $artres = QbankName::paginate(20, false,
            ['type' => 'myPaginate'
            ]);
        $num = count($artres);
        $this->assign('artres', $artres);
        $this->assign('num', $num);
        return view('/qbank/lst');
    }

    /**
     * @param $id
     * @return \think\response\View|void
     */
    public function edit($id)
    {
        if (request()->isPost()) {
            $data = Request::instance()->post();
            $bn['bid'] = $id;
            $bn['bank_name']=$data['bank_name'];
            $bank = new QbankName();
            $save = $bank->update($bn);
            if ($save) {
                $this->success('修改标题成功！');
            } else {
                $this->error('修改标题失败！');
            }
            return;

        }
        if ($this->request->isGet()) {

            if (!is_numeric($id)) {
                return;
            }
            $qbank = QbankName::get($id);
            $this->assign('bank', $qbank);
            return view();
        }

    }
}